import numpy as np
import matplotlib.pyplot as plt
import os

fname = 'fig3f.npz'

# load npz file
data = np.load(fname, allow_pickle=True)
print(data.files)
B_up = data['B_up']
B_down = data['B_down']
Rxy_up = data['Rxy_up']
Rxy_down = data['Rxy_down']
Rxy_asym = data['Rxy_asym']

# plot raw data
fig, ax = plt.subplots()
fig.suptitle('fig3f raw data')
ax.plot(B_up, Rxy_up)
ax.plot(B_down, Rxy_down)
ax.set_xlabel('$B$ (T)')
ax.set_ylabel('$R_{xy}$ raw')
ax.legend()
plt.show()

# plot processed data
fig, ax = plt.subplots()
fig.suptitle('fig3f antisymmetrized data')
ax.plot(B_up, Rxy_asym)
ax.plot(B_down, -Rxy_asym)
ax.set_xlabel('$B$ (T)')
ax.set_ylabel('$R_{xy}$ antisymmetrized')
ax.legend()
plt.show()